package jp.dev7.hongo2.model;

import java.io.Serializable;

import org.slim3.datastore.Attribute;
import org.slim3.datastore.Model;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.Text;

@Model(schemaVersion = 1)
public class Question implements Serializable {

    private static final long serialVersionUID = 1L;

    @Attribute(primaryKey = true)
    private Key key;

    @Attribute(version = true)
    private Long version;

    private Text content;

    private String selection0;

    private String selection1;

    private String selection2;

    private String selection3;

    /**
     * Returns the key.
     * 
     * @return the key
     */
    public Key getKey() {
        return key;
    }

    /**
     * Sets the key.
     * 
     * @param key
     *            the key
     */
    public void setKey(Key key) {
        this.key = key;
    }

    /**
     * Returns the version.
     * 
     * @return the version
     */
    public Long getVersion() {
        return version;
    }

    /**
     * Sets the version.
     * 
     * @param version
     *            the version
     */
    public void setVersion(Long version) {
        this.version = version;
    }

    public Text getContent() {
        return content;
    }

    public void setContent(Text content) {
        this.content = content;
    }

    public String getSelection0() {
        return selection0;
    }

    public void setSelection0(String selection0) {
        this.selection0 = selection0;
    }

    public String getSelection1() {
        return selection1;
    }

    public void setSelection1(String selection1) {
        this.selection1 = selection1;
    }

    public String getSelection2() {
        return selection2;
    }

    public void setSelection2(String selection2) {
        this.selection2 = selection2;
    }

    public String getSelection3() {
        return selection3;
    }

    public void setSelection3(String selection3) {
        this.selection3 = selection3;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((content == null) ? 0 : content.hashCode());
        result = prime * result + ((key == null) ? 0 : key.hashCode());
        result =
            prime * result + ((selection0 == null) ? 0 : selection0.hashCode());
        result =
            prime * result + ((selection1 == null) ? 0 : selection1.hashCode());
        result =
            prime * result + ((selection2 == null) ? 0 : selection2.hashCode());
        result =
            prime * result + ((selection3 == null) ? 0 : selection3.hashCode());
        result = prime * result + ((version == null) ? 0 : version.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Question other = (Question) obj;
        if (content == null) {
            if (other.content != null)
                return false;
        } else if (!content.equals(other.content))
            return false;
        if (key == null) {
            if (other.key != null)
                return false;
        } else if (!key.equals(other.key))
            return false;
        if (selection0 == null) {
            if (other.selection0 != null)
                return false;
        } else if (!selection0.equals(other.selection0))
            return false;
        if (selection1 == null) {
            if (other.selection1 != null)
                return false;
        } else if (!selection1.equals(other.selection1))
            return false;
        if (selection2 == null) {
            if (other.selection2 != null)
                return false;
        } else if (!selection2.equals(other.selection2))
            return false;
        if (selection3 == null) {
            if (other.selection3 != null)
                return false;
        } else if (!selection3.equals(other.selection3))
            return false;
        if (version == null) {
            if (other.version != null)
                return false;
        } else if (!version.equals(other.version))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "Question [key="
            + key
            + ", version="
            + version
            + ", content="
            + content
            + ", selection0="
            + selection0
            + ", selection1="
            + selection1
            + ", selection2="
            + selection2
            + ", selection3="
            + selection3
            + "]";
    }

}
